XRAM_TO_DATA SEGMENT CODE
DATA_TO_XRAM SEGMENT CODE
	
	PUBLIC	_DATA_TO_XRAM	
	PUBLIC	_XRAM_TO_DATA

XBUS_AUX	DATA	0A2H

; R7 data target
; R5 xdata
	RSEG  XRAM_TO_DATA
_XRAM_TO_DATA:
	MOV A,R7
	MOV R1,A
	MOV DPH,#01H
	MOV DPL,R5
	
	MOVX A,@DPTR
	MOV @R1,A
	INC R1
	INC DPL
	MOVX A,@DPTR
	MOV @R1,A
	INC R1
	INC DPL
	MOVX A,@DPTR
	MOV @R1,A
	INC R1
	INC DPL
	MOVX A,@DPTR
	MOV @R1,A
	INC R1
	INC DPL

	RET

; R5 data
; R7 xdata
	RSEG DATA_TO_XRAM
_DATA_TO_XRAM:
	INC XBUS_AUX
	MOV DPH,#02H
	MOV DPL,R7
	DEC XBUS_AUX
	MOV A,R5
	MOV R1,A
	
	MOV A,@R1
	DB 0A5H
	INC R1
	MOV A,@R1
	DB 0A5H
	INC R1
	MOV A,@R1
	DB 0A5H
	INC R1
	MOV A,@R1
	DB 0A5H
	INC R1
	
	RET

END